package com.demo.core.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.demo.base.model.WebUserForPerson;
import com.demo.base.util.CommonUtil;

@Repository
public class WebUserForPersonDao extends BaseDao{

	/**
	 * 网上用户登录
	 * @param loginName
	 * @param password
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public WebUserForPerson authWebUserForPerson(String loginName,String password){
		
		Session session = this.getSession();
		
		Query query = session.createQuery("from WebUserForPerson where loginName=:loginName and password=:password");
		query.setString("loginName", loginName);
		query.setString("password", password);
		List<WebUserForPerson> list = query.list();
		if(CommonUtil.isNull(list)){
			
			return null;
		}else{
			return list.get(0);
		}
	}
}
